<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
  
  <xsl:template match="/gidootml">
    <xsl:apply-templates />
  </xsl:template>

  <!-- ignore di for now -->
  <xsl:template match="di" priority="1">
    <xsl:apply-templates />
  </xsl:template>
  
  <!-- ignore sections for now -->
  <xsl:template match="section" priority="1">
    <xsl:apply-templates />
  </xsl:template>
  
  
  <!-- headings, use section as decision helper and default to h1 -->
  <xsl:template match="section/section/section/section/section/h" priority="6">
    <h6>
      <xsl:for-each select="@*"><xsl:attribute name="{name()}"><xsl:value-of 
  select="."/></xsl:attribute>
      </xsl:for-each>
      
      <xsl:apply-templates />
    </h6>
  </xsl:template>
  
  <xsl:template match="section/section/section/section/h" priority="5">
    <h5>
      <xsl:for-each select="@*"><xsl:attribute name="{name()}"><xsl:value-of 
  select="."/></xsl:attribute>
      </xsl:for-each>
      
      <xsl:apply-templates />
    </h5>
  </xsl:template>
  
  <xsl:template match="section/section/section/h" priority="4">
    <h4>
      <xsl:for-each select="@*"><xsl:attribute name="{name()}"><xsl:value-of 
  select="."/></xsl:attribute>
      </xsl:for-each>
      
      <xsl:apply-templates />
    </h4>
  </xsl:template>
  
  <xsl:template match="section/section/h" priority="3">
    <h3>
      <xsl:for-each select="@*"><xsl:attribute name="{name()}"><xsl:value-of 
  select="."/></xsl:attribute>
      </xsl:for-each>
      
      <xsl:apply-templates />
    </h3>
  </xsl:template>
 
  <xsl:template match="section/h" priority="2">
    <h2>
      <xsl:for-each select="@*"><xsl:attribute name="{name()}"><xsl:value-of 
  select="."/></xsl:attribute>
      </xsl:for-each>
      
      <xsl:apply-templates />
    </h2>
  </xsl:template>

  <xsl:template match="h" priority="1">
    <h1>
      <xsl:for-each select="@*"><xsl:attribute name="{name()}"><xsl:value-of 
  select="."/></xsl:attribute>
      </xsl:for-each>
      
      <xsl:apply-templates />
    </h1>
  </xsl:template>
    
  <!-- end headings -->
  
  <!-- blockcode -->
  <xsl:template match="blockcode" priority="1">
    <pre><code>
        <xsl:for-each select="@*"><xsl:attribute name="{name()}"><xsl:value-of 
    select="."/></xsl:attribute>
        </xsl:for-each>

        <xsl:apply-templates />
    </code></pre>
  </xsl:template>
  
   <!-- copy all default elements -->
  <xsl:template match="*" priority="-1">
    <xsl:element name="{name()}">
      <xsl:for-each select="@*"><xsl:attribute name="{name()}"><xsl:value-of 
  select="."/></xsl:attribute>
      </xsl:for-each>
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>

</xsl:stylesheet>
